package net.tmaize.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class JsonUtils {

	/**
	 * 获取json字符串
	 * @author 宇明
	 * @throws IOException
	 */
	public static String getJsonStr(String httpUrl) throws IOException {

		BufferedReader reader = null;
		StringBuffer sbf = new StringBuffer();
		
		URL url = new URL(httpUrl);
		HttpURLConnection connection = (HttpURLConnection) url.openConnection();
		connection.setRequestMethod("GET");
		connection.connect();
		InputStream is = connection.getInputStream();
		reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
		String strRead = null;
		while ((strRead = reader.readLine()) != null) {
			sbf.append(strRead);
			sbf.append("\r\n");
		}
		reader.close();
		return sbf.toString();
	}
}
